package com.atguigu.lease.web.admin.custom.comverter;

import com.atguigu.lease.model.enums.ItemType;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;


/**
 * description:
 *
 * @author:MING
 * @time:2025-02-25-16:59-25
 * @version:
 */

@Component
public class StringToItemTypeConverter implements Converter<String, ItemType> {
    @Override
    public ItemType convert(String code) {

        for (ItemType value : ItemType.values()) {
            if (value.getCode().equals(Integer.valueOf(code))) {
                return value;
            }
        }
        throw new IllegalArgumentException("code非法"+code);
    }
}